#include<unistd.h>
#include<fcntl.h>
#include<string.h>
#include<sys/stat.h>
#include<stdlib.h>
#include<stdio.h>
#include<errno.h>
#include<sys/types.h>
#include<sys/wait.h>
int main(int argc,char** argv)
{
    int status;
    int pid,ppid,wpid;
    pid=fork();
    if(pid==0)
    {
        //子进程
        printf("child pid=%d,childs father ppid=%d\n",getpid(),getppid());
        sleep(5);
        printf("child process is die!\n");//子进程中断


        }else if(pid>0)
        {
            //pid>0:父进程，在父进程中阻塞等待
            wpid=wait(&status);
            if(wpid==-1)
            {
                perror("wait is error!\n");
                exit(1);
                }
             printf("parent wait finish!\n");
            }else
            {
                perror("fork fail!\n");
                exit(1);//退出
                }
return 0;
}
